﻿Imports System.Data

Partial Class CheckOut
    Inherits System.Web.UI.Page

    Protected Sub btnBuscarHabitacion_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBuscarHabitacion.Click
        Dim dvHabitacion As Data.DataView
        sdahabitacion.SelectParameters("Numero").DefaultValue = txtHabitacion.Text
        dvHabitacion = sdahabitacion.Select(DataSourceSelectArguments.Empty)
        If dvHabitacion.Count = 1 Then
            lblHabitacion.Text = dvHabitacion(0)("Numero").ToString
            lblPrecio.Text = dvHabitacion(0)("Precio").ToString
            lblCliente.Text = dvHabitacion(0)("Apellido").ToString & ", " & dvHabitacion(0)("Nombre").ToString
            lblDocumento.Text = dvHabitacion(0)("Documento").ToString
            lblEntrada.Text = dvHabitacion(0)("Entrada").ToString
            lblSalida.Text = Date.Today.ToShortDateString
            lblTotal.Text = Convert.ToDecimal(lblPrecio.Text) * DateDiff(DateInterval.Day, Convert.ToDateTime(lblEntrada.Text), Convert.ToDateTime(lblSalida.Text))
            pnlHabitacion.Visible = False
            pnlCliente.Visible = True
        Else
            lblNoEncontrada.Visible = True
        End If
    End Sub

    Protected Sub btnFacturar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFacturar.Click
        txtFormaDePago.ReadOnly = True
        sdahabitacion.UpdateParameters("Numero").DefaultValue = lblHabitacion.Text
        sdahabitacion.Update()
        btnFacturar.Visible = False
        lblLiberada.Text = lblHabitacion.Text
        Dim dvSql As DataView = DirectCast(sdahabitacion.Select(DataSourceSelectArguments.Empty), DataView)
        'Dim diasEstadia As Integer
        With sdaRendicion
            .InsertParameters.Add("Cliente", lblCliente.Text)

            '.InsertParameters("Fecha").DefaultValue = lblSalida.Text
            '.InsertParameters("Dias").DefaultValue = DateDiff(DateInterval.Day, Convert.ToDateTime(lblEntrada.Text), Convert.ToDateTime(lblSalida.Text))
            '.InsertParameters("Precio").DefaultValue = Convert.ToDecimal(lblPrecio.Text)
            '.InsertParameters("Total").DefaultValue = Convert.ToDecimal(lblTotal.Text)
            '.InsertParameters("Forma").DefaultValue = txtFormaDePago.Text

            'ters.AddWithValue("@p2", TBNombre.Text)

        End With
        pnlCheckedOut.Visible = True
    End Sub
End Class
